<template>
  <div class="myWallet_rule">
    <topUserHead :infoData="infoData"></topUserHead>
    <div class="ruleBox">
      <div class="txt">级别升级规则</div>
      <div class="listBox">
        <div class="list_head">
          <div class="lis pd bg">级别名称</div>
          <div class="lis flex_w bg">升级条件</div>
          <div class="lis pd bg">分红分数</div>
        </div>
        <div class="list_head" v-for="(item, index) in list" :key="index">
          <div class="lis pd">{{ item.level_name }}</div>
          <div class="lis flex_w">消费{{ item.upgrade_points }}元</div>
          <div class="lis pd">{{ item.dividend_count }}</div>
        </div>
        <div class="list_head">
          <div class="lis flex_w" style="color: #AAAAB3;font-size: 0.81rem;">以此类推</div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { scrollMixin } from "utils/mixin";
import topUserHead from "./components/topUserHead.vue";
export default {
  mixins: [scrollMixin],
  data() {
    return {
      infoData: {},
      list: [],
      page: 1,
      total_page: 0,
      isLoadMore: true
    };
  },
  components: { topUserHead },
  activated() {
    this.getData();
    this.getList();
  },
  methods: {
    async getMoreData() {
      if (!this.isLoadMore) {
        return;
      }
      this.isLoadMore = false;
      if (this.page >= this.total_page) return;
      this.page = this.page + 1;
      let json = {
        page: this.page
      };
      let { data, msg, result } = await $http.post("plugin.project-party.frontend.controllers.index.celebrityList", json, "");
      this.isLoadMore = true;
      if (result) {
        this.list = this.list.concat(data.list.data);
      } else {
        this.isLoadMore = false;
        this.$toast(msg);
        this.page = this.page - 1;
      }
    },
    async getList() {
      let { data, msg, result } = await $http.post(
        "plugin.project-party.frontend.controllers.index.celebrityList",
        {
          page: this.page
        },
        ""
      );
      if (result) {
        this.list = data.list.data;
        this.total_page = data.list.pages;
        this.isLoadMore = true;
      } else {
        this.$toast(msg);
      }
    },
    async getData() {
      let { data, msg, result } = await $http.post("plugin.project-party.frontend.controllers.index.index", {}, "");
      // data.type 1达人 2个人红人 3企业红人 4企业管理者 5企业员工
      if (result) {
        if (data.man_type == 0) {
          this.$dialog
            .confirm({
              title: "提示",
              message: "点击确认跳转申请页面",
              showCancelButton: false
            })
            .then(() => {
              this.$router.replace(this.fun.getUrl("idShop_apply"));
            });
          return;
        }
        this.infoData = data;
      } else {
        this.$toast(msg);
      }
    }
  }
};
</script>
<style lang="scss" scoped>
.bg{
  background-color: #F5F5F5;
}
.ruleBox {
  margin: 0.63rem 0.75rem;
  background: #ffffff;
  border-radius: 0.5rem;
  padding: 0.94rem 0.53rem;
  box-sizing: border-box;
  overflow: hidden;
  .txt {
    font-weight: bold;
    font-size: 0.94rem;
    color: #00001c;
    text-align: left;
    margin-bottom: 0.88rem;
  }
  .listBox {
    display: flex;
    flex-direction: column;
    border-radius: 0.56rem;
    overflow: hidden;
    border-left: 1px solid #dfdfdf;
    border-top: 1px solid #dfdfdf;
    border-right: 1px solid #dfdfdf;

    .list_head {
      display: flex;
      justify-content: space-between;
      border-radius: 0.56rem;
      .lis {
        padding: 0.66rem 0 0.72rem 0;
        border-right: 1px solid #dfdfdf;
        border-bottom: 1px solid #dfdfdf;
      }
      .pd {
        width: 6rem;
        flex-shrink: 0;
      }
      .flex_w {
        flex: 1;
      }
      .lis:last-child {
        border-right: none;
      }
      .flex_a {
        flex: 1;
      }
    }
  }
}
</style>
